package xin.marcher.module.common.enums.inventory;

import com.google.common.collect.Maps;

import java.util.Map;

/**
 * 分桶操作枚举
 */
public enum BucketOperateEnum {

    /**
     * 初始化
     */
    INIT(1, "initOperateProcess", "初始化"),
    /**
     * 增加库存
     */
    ADD_INVENTORY(2, "onlineOperateProcess", "增加库存"),
    /**
     * 上线分桶
     */
    ONLINE(3, "onlineOperateProcess", "上线分桶"),
    /**
     * 分桶扩容
     */
    CAPACITY(4, "capacityOperateProcess", "分桶扩容"),
    /**
     * 下线分桶
     */
    OFFLINE(5, "offlineOperateProcess", "下线分桶"),
    ;

    private Integer code;

    private String service;

    private String value;

    BucketOperateEnum(Integer code, String service, String value) {
        this.code = code;
        this.service = service;
        this.value = value;
    }

    public Integer getCode() {
        return code;
    }

    public String getService() {
        return service;
    }

    public String getValue() {
        return value;
    }

    public static Map<Integer, String> toMap() {
        Map<Integer, String> map = Maps.newHashMap();
        for (BucketOperateEnum element : BucketOperateEnum.values()) {
            map.put(element.getCode(), element.getValue());
        }
        return map;
    }

    public static BucketOperateEnum getByCode(Integer code) {
        if (code == null) {
            return null;
        }
        for (BucketOperateEnum element : BucketOperateEnum.values()) {
            if (code.equals(element.getCode())) {
                return element;
            }
        }
        return null;
    }
}